package this引用;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-06-22
 * Time: 15:43
 */
class Data{//一个时间类
    //成员变量
    public int year;
    public int month;
    public int day;
    //构造方法
    public Data() {
        //System.out.println("该方法被调用了"); 这里代码不放放开注释，因为this(参数)必须在代码第一行
        this(2022,6,22);

    }

    public Data(int year, int month, int day) {
        this.year = year;
        this.month = month;
        this.day = day;
    }

    //成员方法
    public void setDay(int year,int month,int day){
        this.year = year;
        this.month = month;
        this.day = day;
    }
    public void printDay(){

        System.out.println(year+"/"+month+"/"+day);
    }
}
public class Test {
    public static void main(String[] args) {
        Data data1 = new Data();
        //data1.setDay(2022,6,22);
        data1.printDay();
    }
}
